import { createRouter, createWebHistory } from 'vue-router'
import NProgress from 'nprogress'
import 'nprogress/nprogress.css'  //导入进度条样式

//导入路由表
import routes from './routes'

const router = createRouter({
  history: createWebHistory(import.meta.env.BASE_URL),
  routes  //应用路由表
})

//全局前置守卫函数
router.beforeEach((to, from, next) => {

  NProgress.start()

  next()

})

//全局后置守卫函数
router.afterEach((to, from) => {
  NProgress.done()

})

export default router
